package ACWing._1267_清点人数;

import java.io.*;
import java.util.Scanner;

public class Main {
    static int N = 500010;
    static int[] a = new int[N];
    static int[] c = new int[N];

    static int lowbit(int x){
        return x & -x;
    }

    static void add(int x,int d){
        for(int i=x;i<N;i+=lowbit(i))
            c[i] +=d;
    }

    static long sum(int x){
        long ans = 0;
        for(int i=x;i>0;i-=lowbit(i))
            ans += c[i];
        return ans;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] comd = reader.readLine().split(" ");
        int n = Integer.parseInt(comd[0]);
        int k = Integer.parseInt(comd[1]);
        for (int i = 0; i < k; i++) {
            comd = reader.readLine().split(" ");
            if(comd[0].equals("A")){
                int m = Integer.parseInt(comd[1]);
//                System.out.println(m);
                writer.write(sum(m)+"\n");
            }else if(comd[0].equals("B")){
                int m = Integer.parseInt(comd[1]);
                int p = Integer.parseInt(comd[2]);
//                System.out.println(m+" "+p);
                add(m,p);
            }else{
                int m = Integer.parseInt(comd[1]);
                int p = Integer.parseInt(comd[2]);
//                System.out.println(m+" "+p);
                add(m,-p);
            }
        }
        writer.flush();
        reader.close();
        writer.close();
    }
}
